package com.commons.exception;


import org.apache.commons.lang3.StringUtils;

public class EntityExistException extends RuntimeException {

    public EntityExistException(Class clazz,String field,String val) {
        super(EntityExistException.generateMessage(clazz.getSimpleName(), field, val));
    }

    private static String generateMessage(String entity, String field, String val) {
        //首字母大写
        return StringUtils.capitalize(entity)
                + " with " + field + " "+ val + " existed";
    }
}
